<%@ page contentType="text/html;charset=utf-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<html>
	<head>
		<title>住宿时限管理</title>
		<link rel="stylesheet"
			href="<%=request.getContextPath()%>/css/common.css" type="text/css" />
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="this is my page">
		<meta http-equiv="content-type" content="text/html; charset=UTF-8">
		<!-- 使用struts 2的 datetimepicher 必须有这个头文件 -->
		<s:head theme="ajax" />
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/interface/studentLodgeMgrAction.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/engine.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/dwr/util.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/jquery-latest.pack.js'></script>
		<script type='text/javascript'
			src='<%=request.getContextPath()%>/js/page_nav_js.js'></script>
		<script type="text/javascript">
		var studentno; //全局变量
		
		
		//根据学号去查住宿时限信息
		function onSearchStudentLodgeTimeSubmit(){
		studentno = $("studentno").value;
		if(studentno==""){
		alert("请输入学号!");
		return false;
		}
		studentLodgeMgrAction.getlodgeTimeMgrInfoByStudentNo(studentno,searchlodgetimeinfocb);
		}
		var  searchlodgetimeinfocb = function searchlodgetimeinfo_cb(timeInfoList){
		if(timeInfoList==null){
		alert("查询到指定学号的学生住宿信息为空!");
		return;
		}
		if($('stutimeinf').style.visibility == 'hidden'){
			$('stutimeinf').style.visibility = 'visible';
		}
		
		// studentid, studentname, studentno, studentbedstartintime,
		// studentbedendouttime, dormitorydisplayname, dormitoryid
		      dwr.util.setValue("studentid" ,timeInfoList[0]); //隐藏项目
		      dwr.util.setValue("dormitoryid",timeInfoList[6]);//隐藏项目
		      dwr.util.setValue("studentname",timeInfoList[1]);
		      dwr.util.setValue("student_no",timeInfoList[2]);
		     // dwr.util.setValue("studentbedstartintime",timeInfoList[3]);
		     // dwr.util.setValue("studentbedendouttime",timeInfoList[4]);
		     var time1= dojo.widget.byId("studentbedstartintime");
   			 time1.setValue(timeInfoList[3]);
		     var time2= dojo.widget.byId("studentbedendouttime");
   			 time2.setValue(timeInfoList[4]);
		     dwr.util.setValue("dormitorydisplayname",timeInfoList[5]);
		}
		
		function updateLodgeTimeInfo(){
		var student_id = $("studentid").innerHTML;
		var startintime= dojo.widget.byId("studentbedstartintime").getValue();
		var endouttime= dojo.widget.byId("studentbedendouttime").getValue();
		//alert(endouttime);
		//alert(student_id);
		studentLodgeMgrAction.updateLodgeTimeMgrInfo(student_id,startintime,endouttime,updatelodgetimecb);
		}
		var updatelodgetimecb = function updatelodgetime_cb(status){
		alert(status);
		studentLodgeMgrAction.getlodgeTimeMgrInfoByStudentNo(studentno,searchlodgetimeinfocb);
		}		
		
		//enter键按下提交搜索
	 	function submit(eventTag){
		 	var event = eventTag||window.event;    
	   		var currentKey = event.charCode||event.which;  
				if(currentKey==13){ 
					onSearchStudentLodgeTimeSubmit();
				}
		} 
		document.onkeydown = submit;
		
		</script>
	</head>
	<body>
		<div id="page_container">
			<div id="page_nav">
				<!--
				<span><a
					href="<%=request.getContextPath()%>/lodgemgr/#">住宿时限查询</a></span>
					-->
				<a href="<%=request.getContextPath()%>/lodgemgr/lodgetimemgr.jsp"><span>住宿时限管理</span>
				</a>
			</div>
			<h2>
				住宿时限
			</h2>
			<div align="center">
				学号：
				<input type="text" id="studentno" name="studentno" />
				<input class="common_button" type="submit" value="提交"
					onclick="javascript:onSearchStudentLodgeTimeSubmit();" />
			</div>
			<table id="stutimeinf" style="visibility: hidden;" class="table_common">
				<tr>
					<td class="td_left">
						姓名:
					</td>
					<td class="td_right">
						<div id="studentname"></div>
					</td>
				</tr>
				<tr>
					<td class="td_left">
						学号:
					</td>
					<td class="td_right">
						<div id="student_no"></div>
					</td>
				</tr>
				<tr>
					<td class="td_left">
						开始入住时间:
					</td>
					<td class="td_right">
						<s:datetimepicker name="startInDate" id="studentbedstartintime"
							displayFormat="yyyy-MM-dd" theme="simple" />
					</td>
				</tr>
				<tr>
					<td class="td_left">
						结束入住时间:
					</td>
					<td class="td_right">
						<s:datetimepicker name="endOutDate" id="studentbedendouttime"
							displayFormat="yyyy-MM-dd" theme="simple" />
					</td>
				</tr>
				<tr>
					<td class="td_left">
						宿舍名称:
					</td>
					<td class="td_right">

						<div id="dormitorydisplayname"></div>
					</td>
				</tr>
				<tr class="table_submit">
					<td colspan="2">
						<input class="common_button" type="submit" value="修改时限"
							onclick="javascript:updateLodgeTimeInfo();">
					</td>
				</tr>
			</table>
			<div id="studentid" style="visibility: hidden;"></div>
			<div id="dormitoryid" style="visibility: hidden;"></div>
		</div>
		<script type="text/javascript">	
			window.onload = function(){
				var nav_a=$j('#page_nav a');
				var nav_span=$j("#page_nav a span");
				for(var u = 0 ;u<nav_a.length;u++){
						nav_a.get(u).style.backgroundPosition="left top";
						nav_span.get(u).style.backgroundPosition="right top";							
				}
				$j('#page_nav a').get(0).style.backgroundPosition="0% -42px";
				$j("#page_nav a span").get(0).style.backgroundPosition="100% -42px";
			}	
		</script>
	</body>
</html>